package common.post.service;

import java.util.List;

import common.post.bean.Contacts;
import common.post.dao.ContactsDao;

public class ContactsServiceImpl implements ContactsService {
	private ContactsDao contactsDao;
	@Override
	public boolean addContacts(Contacts contacts) {
		int id = this.contactsDao.save(contacts);
		if(id==0){
			return false;
		}
		return true;
	}
	@Override
	public Contacts getContactByContact(String contact) {
		if(contact==null || "".equals(contact.trim())){
			return null;
		}
		List<Contacts> list = this.contactsDao.find("from Contacts c where c.content='"+contact+"'");
		if(list.size()>0){
			return list.get(0);
		}else{
			return null;
		}
	}
	//--------------------getter and setter method----------------------
	public ContactsDao getContactsDao() {
		return contactsDao;
	}
	public void setContactsDao(ContactsDao contactsDao) {
		this.contactsDao = contactsDao;
	}
	
	
}
